#include<bits/stdc++.h>
using namespace std;
namespace IO{
    const int BUF=1<<21;
    char buff[BUF],*p1=buff,*p2=buff;
    #define gc() (p1==p2&&(p2=((p1=buff)+fread(buff,1,BUF,stdin)),p1==p2)?EOF:*p1++)
    template<typename T>inline void read(T &x){
        char ch=gc();x=0;int f=1;
        while(!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}
        while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=gc();
        x*=f;
    }
}
using namespace IO;
const int N=5e5+5;
int n,k,a[N],b[N],w[N],idx,t[N],s[N];
inline void add(int x,int y){
	for(;x<=idx&&t[x]<y;x+=x&-x) t[x]=y;
}
inline int query(int x){
	int ans=0;
	for(;x;x-=x&-x) ans=max(ans,t[x]);
	return ans;
}
inline bool check(int mid){
	for(int i=1;i<=idx;++i) t[i]=0;
	for(int i=1,j=idx;i<=idx;++i){
		while(j&&w[i]+w[j]>mid) --j;
		s[i]=j;
	}
	int mx=0;
	for(int i=1;i<=n;++i) if(s[a[i]]){
		int f=query(s[a[i]])+1;
		mx=max(mx,f);
		if(f>=k) return 1;
		if(mx+n-i<k) return 0;
		add(a[i],f);
	}
	return 0;
}
int main(){
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	read(n),read(k);
	int fir=1;
	for(int i=1;i<=n;++i){
		read(a[i]);
		if(a[i]<a[fir]) fir=i;
	}
	for(int i=1;i<=n;++i){
		if(i<fir) b[n-fir+1+i]=a[i];
		else b[i-fir+1]=a[i];
	}
	swap(a,b);
	for(int i=1;i<=n;++i) w[i]=a[i];
	sort(w+1,w+n+1);
	idx=unique(w+1,w+n+1)-w-1;
	for(int i=1;i<=n;++i) a[i]=lower_bound(w+1,w+idx+1,a[i])-w;
	long long l=w[1]+w[2],r=2e9,mid,ans=2e9;
	while(l<=r){
		mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans;
	return 0;
}


